﻿using CompanyManageSystem.DLL;
using CompanyManageSystem.IService;
using CompanyManageSystem.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompanyManageSystem.Service
{
    public class TestService : ITestService
    {
        private IRepository<Material> mRository;

        public TestService() : this(new PSContext()){}

        public TestService(DbContext dbContext)
        {
            //mRository = new BaseRepository<Material>(dbContext);
        }

        public void AddMaterial()
        {
            Material material = new Material
            {
                ID = Guid.NewGuid(),
                Name = "大米",
                CreateTime = DateTime.Now
            };
            this.mRository.Add(material);
            this.mRository.Commit();
        }

        public void UpdateMaterial(Material material)
        {
            //PSContext _db = new PSContext();
            //Material material = new Material
            //{
            //    ID = new Guid("3F23EC06-79F8-4F28-9944-FEDECB891A1B"),
            //    Name = "桂花",
            //};
            material.Name = "桂花";
            this.mRository.Update(material);
            int i = this.mRository.Commit();
        }


    }
}
